<html>
	<head>
	<title>在线服务点餐</title>
	
	</head>
	<body>
		<form name="myform" id="myform">
			<label>
				饮料(只能选择一种)：
			</label>
			
			<select name="drink" id="drink" size="1">
				
                <option selected>可乐</option>
                <option>雪碧</option>
				<option>咖啡</option>
			</select>
			
			<br>
			
			<label>
				主食（可以多选）:
			</label>
			
			<select multiple="multiple" name="food" id="food" size="5">
				<option>面包</option>
				<option>饼干</option>
				<option>米饭</option>
				<option>炒菜</option>
				<option>汉堡</option>
			</select>
			<input type="submit" onclick="showEnd()" value="提交">
		</form>
		
	    <script language="javascript">
            function showEnd(){   
                //var myDrink = document.getElementById("#drink");
                var myfood = document.getElementById("food");
                var array = new Array();
                var string=""
                for(var i = 0; i < myfood.length; i++){
                    if(myfood.options[i].selected){
                        array.push(myfood.options[i].value);
                    }
                }

                for(var i = 0; i < array.length; i++){
                    string = array[i] + " " + string;
                }
                var w=window.open();
                w.document.open();
                w.document.write("<h1>" + "您选择的饮料为：" + drink.value +"</h1>" + "<br>");
                w.document.write("<h1>" + "您选择的主食为：" + string + "</h1>");
                w.document.close();
                
                
            
            }

        </script>

	</body>
</html>